<template>
  <div class="content">
    <div class="topBanner">
      <div class="top-center">
        <span>News Information</span>
      </div>
      <div class="line">
        <div class="top-line1" />
        <div class="top-line2" />
      </div>
    </div>
    <div class="artral">
      <div class="artral-left">
        <div class="left-top">
          <div class="left-date">The News</div>
        </div>
        <div v-if="!tableData.length" class="nodata">
          <img style="width: 20%;" src="@/assets/loginImgs/nodata.png" alt="">
        </div>
        <div
          v-for="item in tableData"
          :key="item.id"
          class="left-center"
          @click="toLink(item.article.id)"
        >
          <div class="leftImg">
            <img :src="imgPrefix + item.article.coverUri" alt="">
          </div>
          <div class="leftDsc">
            <div class="date">
              {{ item.article.publishedTime }}
            </div>
            <div class="dsc">
              {{ item.article.title }}
            </div>
          </div>
        </div>
        <div v-if="tableData.length > 10" style="text-align: center;text-align: center;padding: 10px 0;border-top: 1px solid #e6e6e6;">
          <el-pagination
            background
            :current-page="pageNo"
            :page-size="pageSize"
            :total="total"
            layout="prev, pager, next"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
      </div>
      <!-- <div class="artral-right">
        <div>
          <div class="right-name">
            <ul>
              <li>
                <span>The company dynamic</span>
                <img src="@/assets/loginImgs/newsJ.png" alt="">
              </li>
              <li>
                <span>Function is introduced</span>
                <img src="@/assets/loginImgs/newsJ.png" alt="">
              </li>
              <li>
                <span> New products listed</span>
                <img src="@/assets/loginImgs/newsJ.png" alt="">
              </li>
              <li>
                <span>Policies and regulations</span>
                <img src="@/assets/loginImgs/newsJ.png" alt="">
              </li>
            </ul>
          </div>
        </div>
        <div>
          <div class="right-name">
            <div class="right-title">
              <p>The latest article</p>
            </div>
            <div class="right-detial">
              <div class="code">
                <img src="@/assets/loginImgs/code.png" alt="">
              </div>
              <div class="address">
                <p>China</p>
                <p>Email: holosie@hotmail.com</p>
                <p>Phone :+86 18137139989</p>
                <p>Location:</p>
                <p>ZhengZhou,HeNan,China</p>
              </div>
            </div>
          </div>
        </div>
      </div> -->
    </div>
  </div>
</template>

<script>
import { articlePage } from '@/api/article';
export default {
  data() {
    return {
      tableData: [],
      loading: false,
      pageNo: 1,
      pageSize: 10,
      nextId: '',
      preId: '',
      total: 0
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      this.loading = true;
      articlePage({
        articleCategoryId: -1,
        beginCreateTime: '',
        endCreateTime: '',
        title: '',
        type: 0,
        pageNo: this.pageNo,
        pageSize: this.pageSize
      }).then((res) => {
        this.tableData = res.data.data;
        this.tableData.map((val) => {
          val.article.publishedTime = val.article.publishedTime.split(' ')[0];
        });
        this.total = res.data.totalCount;
        this.loading = false;
      });
    },
    toLink(id, index) {
      this.$router.push({
        path: '/home/newsDetial',
        query: { id: id }
      });
    },
    handleSizeChange(val) {
      this.pageSize = val;
      this.init();
    },
    handleCurrentChange(val) {
      this.pageNo = val;
      this.init();
    }
  }
};
</script>
<style lang="scss" scoped>
.nodata {
  text-align: center;
  margin-top: 50px;
}
.content {
  width: 100%;
  height: 100%;
  min-width: 1200px;
  margin-top: 70px;
  padding-bottom: 40px;
  font-family: Segoe UI;
  border: 1px solid #e6e6e6;
  background: #f9f9f9;
}
::v-deep .el-pagination .active {
  background-color: #02a152 !important;
}
.topBanner {
  text-align: center;
  height: 400px;
  background: url('../../assets/loginImgs/news.png') no-repeat;
  background-size: 100% 100%;
  overflow: hidden;
  .top-center {
    font-size: 80px;
    font-weight: bold;
    line-height: 80px;
    color: #000000;
    margin-top: 70px;
    opacity: 1;
  }
  .line {
    width: 930px;
    margin: 0 auto;
    .top-line1 {
      width: 930px;
      height: 8px;
      margin-top: 25px;
      background: rgba(0, 0, 0, 1);
      opacity: 1;
    }
    .top-line2 {
      width: 630px;
      height: 8px;
      margin-top: 45px;
      background: rgba(0, 0, 0, 1);
      opacity: 1;
    }
  }
}
.artral {
  width: 1200px;
  margin: 0 auto;
  margin-top: 40px;
  vertical-align: top;
  &-left {
    min-height: 400px;
    margin: 0 auto; //修改
    padding: 20px;
    padding-bottom: 0;
    background: rgba(255, 255, 255, 1);
    border: 1px solid #e6e6e6;
    .left-top {
      margin: 0 auto;
      display: flex;
      justify-content: space-between;
    }
    .left-center {
      color: rgba(102, 102, 102, 1);
      padding: 20px;
      padding-left: 0;
      display: flex;
      justify-content: space-between;
      border-top: 1px solid #e6e6e6;
      .leftImg {
        width: 320px;
        height: 170px;
        border-radius: 4px;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .leftDsc {
        width: 850px; // 修改
        height: 170px;
        padding: 0 30px;
        .dsc {
          line-height: 20px;
          font-size: 20px;
          color: #333333;
          font-weight: 600;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 3;
          word-wrap: break-word;
          -webkit-box-orient: vertical;
        }
        .date {
          font-size: 18px;
          font-weight: 400;
          padding-bottom: 20px;
          color: #666666;
        }
      }
    }
    .left-date {
      font-size: 24px;
      padding: 0 10px;
      color: rgba(102, 102, 102, 1);
      opacity: 1;
      display: inline-block;
      border-bottom: 3px solid rgba(2, 161, 82, 1);
    }
  }
  &-right {
    vertical-align: top;
    display: inline-block;
    margin-left: 30px;
    .right-title {
      width: calc(100vw / 5.89);
      margin: 0 auto;
      text-align: center;
      font-size: calc(100vw / 80);
      color: rgba(51, 51, 51, 1);
      p {
        padding-top: calc(100vw / 64);
        font-weight: 600;
      }
    }
    .right-detial {
      .code {
        width: calc(100vw / 9.6);
        height: calc(100vw / 9.6);
        margin: calc(100vw / 64);
        padding-right: calc(100vw / 128);
        margin-right: 0;
        display: inline-block;
        border-right: calc(100vw / 960) solid #707070;
        img {
          // width: 100%;
          height: 100%;
        }
      }
      .address {
        font-size: calc(100vw / 106.67);
        margin: calc(100vw / 32) 0;
        padding-left: calc(100vw / 128);
        display: inline-block;
        vertical-align: top;
      }
    }
    .right-name {
      width: calc(100vw / 3.82);
      background: rgba(255, 255, 255, 1);
      margin-bottom: calc(100vw / 64);
      box-shadow: 0px 0px calc(100vw / 320) rgba(0, 0, 0, 0.16);
      opacity: 1;
      border-radius: calc(100vw / 480);
      line-height: calc(100vw / 71.11);
      ul {
        list-style-type: none;
        padding: 0;
        margin: 0;
        li {
          font-size: calc(100vw / 80);
          font-weight: 600;
          padding: calc(100vw / 96) calc(100vw / 48);
          color: rgba(51, 51, 51, 1);
          border-bottom: 1px solid #e6e6e6;
          img {
            width: calc(100vw / 192);
            height: calc(100vw / 83.47);
            float: right;
            padding-top: calc(100vw / 274.29);
          }
        }
      }
    }
  }
}
</style>
